package com.mate.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * <p>
 * Spring Boot项目中加载自定义的yaml文件
 * </p>
 *
 * @author: MI
 * @email: 448341911@qq.com
 * @createTime: 2024/5/29 14:58
 * @updateUser: MI
 * @updateTime: 2024/5/29 14:58
 * @updateRemark: 修改内容
 * @version: v1.0
 */
@SpringBootApplication
public class SpringBootYamlApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext ctx = SpringApplication.run(SpringBootYamlApplication.class, args);

        ConfigurableEnvironment env = ctx.getEnvironment();
        env.getPropertySources().forEach(ps -> System.out.println(ps.getName() + " : " + ps.getClass()));
        System.out.println("Value of `seata.application-id` = ：" + env.getProperty("seata.application-id"));
        System.out.println("Value of `seata.config.nacos.server-addr` = " + env.getProperty("seata.config.nacos.server-addr"));
        System.out.println("Value of `seata.config.type` = ：" + env.getProperty("seata.config.type"));
    }

}
